package cn.fx.fallback;

import cn.fx.result.JsonResult;
import cn.itsource.feign.MovieFeignService;
import cn.itsource.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: springcloud-machinetest
 * @BelongsPackage: cn.itsource.fallback
 * @Author: Director
 * @CreateTime: 2022-09-01  11:28
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class MovieFeignServiceFallbackFatory implements FallbackFactory<MovieFeignService> {
    @Override
    public MovieFeignService create(Throwable throwable) {
        return new MovieFeignService() {
            @Override
            public JsonResult list() {
                return JsonResult.error("服务不可达，请稍后重试！", "500");
            }

            @Override
            public JsonResult buy(Long userId, Long movieId) {
                return JsonResult.error("服务不可达，请稍后重试！", "500");
            }

            @Override
            public JsonResult watch(Long userId, Long movieId) {
                return JsonResult.error("服务不可达，请稍后重试！", "500");
            }
        };
    }
}
